#include <buola/net/cxmlrpccall.h>

namespace buola { namespace io {

CXMLRPCCall::CXMLRPCCall(const std::string &pMethod)
{
    mXML.Create("methodCall");
    xml::CNode lRoot=mXML.Root();
    lRoot.NewChild("methodName",pMethod);
    mParams=lRoot.NewChild("params");
}

void CXMLRPCCall::AddParam(int pValue)
{
    AddParam("int",to_string(pValue));
}

void CXMLRPCCall::AddParam(bool pValue)
{
    AddParam("boolean",pValue?"1":"0");
}

void CXMLRPCCall::AddParam(const std::string &pValue)
{
    AddParam("string",pValue);
}

void CXMLRPCCall::AddParam(double pValue)
{
    AddParam("double",to_string(pValue));
}

void CXMLRPCCall::AddParam(const CXMLRPCArray &pArray)
{
    mParams.NewChild("param").NewChild("value").Append(pArray.XML());
}

void CXMLRPCCall::AddParam(const std::string &pType,const std::string &pValue)
{
    mParams.NewChild("param").NewChild("value").NewChild(pType,pValue);
}

/*namespace io*/ } /*namespace buola*/ }
